package com.javacommunity.model.entity;

// Generated Nov 25, 2014 11:55:44 PM by Hibernate Tools 3.4.0.CR1

import java.util.ArrayList;
import java.util.Date;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import static javax.persistence.GenerationType.IDENTITY;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import org.hibernate.annotations.Fetch;
import org.hibernate.annotations.FetchMode;


/**
 * Post generated by hbm2java
 */
@SuppressWarnings("serial")
@Entity
@Table(name = "post", catalog = "db_javadanang")
public class Post implements java.io.Serializable {

    private Integer postId;
    private Category category;
    private User user;
    private String title;
    private String content;
    private String attachPath;
    private Date createDate;
    private Date updateDate;
    private int viewCount;
    private boolean active;
    private List<Comment> comments = new ArrayList<Comment>();
    private List<UserPost> userPosts = new ArrayList<UserPost>();

    public Post() {
    }

    public Post(Category category, User user, String title, String content,
            Date createDate, Date updateDate, int viewCount, boolean active) {
        this.category = category;
        this.user = user;
        this.title = title;
        this.content = content;
        this.createDate = createDate;
        this.updateDate = updateDate;
        this.viewCount = viewCount;
        this.active = active;
    }

    public Post(Category category, User user, String title, String content,
            String attachPath, Date createDate, Date updateDate, int viewCount,
            boolean active, List<Comment> comments, List<UserPost> userPosts) {
        this.category = category;
        this.user = user;
        this.title = title;
        this.content = content;
        this.attachPath = attachPath;
        this.createDate = createDate;
        this.updateDate = updateDate;
        this.viewCount = viewCount;
        this.active = active;
        this.comments = comments;
        this.userPosts = userPosts;
    }

    @Id
    @GeneratedValue(strategy = IDENTITY)
    @Column(name = "postId", unique = true, nullable = false)
    public Integer getPostId() {
        return this.postId;
    }

    public void setPostId(Integer postId) {
        this.postId = postId;
    }

    @ManyToOne(fetch = FetchType.EAGER)
    @Fetch (FetchMode.SELECT)
    @JoinColumn(name = "categoryId", nullable = false)
    public Category getCategory() {
        return this.category;
    }

    public void setCategory(Category category) {
        this.category = category;
    }

    @ManyToOne(fetch = FetchType.EAGER)
    @Fetch (FetchMode.SELECT)
    @JoinColumn(name = "userId", nullable = false)
    public User getUser() {
        return this.user;
    }

    public void setUser(User user) {
        this.user = user;
    }

    @Column(name = "title", nullable = false, length = 145)
    public String getTitle() {
        return this.title;
    }

    public void setTitle(String title) {
        this.title = title;
    }

    @Column(name = "content", nullable = false, length = 65535)
    public String getContent() {
        return this.content;
    }

    public void setContent(String content) {
        this.content = content;
    }

    @Column(name = "attachPath", length = 105)
    public String getAttachPath() {
        return this.attachPath;
    }

    public void setAttachPath(String attachPath) {
        this.attachPath = attachPath;
    }

    @Temporal(TemporalType.DATE)
    @Column(name = "createDate", nullable = false, length = 10)
    public Date getCreateDate() {
        return this.createDate;
    }

    public void setCreateDate(Date createDate) {
        this.createDate = createDate;
    }

    @Temporal(TemporalType.DATE)
    @Column(name = "updateDate", nullable = false, length = 10)
    public Date getUpdateDate() {
        return this.updateDate;
    }

    public void setUpdateDate(Date updateDate) {
        this.updateDate = updateDate;
    }

    @Column(name = "viewCount", nullable = false)
    public int getViewCount() {
        return this.viewCount;
    }

    public void setViewCount(int viewCount) {
        this.viewCount = viewCount;
    }

    @Column(name = "active", nullable = false)
    public boolean isActive() {
        return this.active;
    }

    public void setActive(boolean active) {
        this.active = active;
    }

    @OneToMany(fetch = FetchType.EAGER, mappedBy = "post")
    @Fetch (FetchMode.SELECT)
    public List<Comment> getComments() {
        return this.comments;
    }

    public void setComments(List<Comment> comments) {
        this.comments = comments;
    }

    @OneToMany(fetch = FetchType.LAZY, mappedBy = "post")
    public List<UserPost> getUserPosts() {
        return this.userPosts;
    }

    public void setUserPosts(List<UserPost> userPosts) {
        this.userPosts = userPosts;
    }

}
